package com.kb.design.util;

import java.util.Random;

public class ColorUtils {

    // 预定义颜色数组
//    private static final String[] COLORS = {"blue", "indigo", "yellow", "green", "red", "purple", "orange"};

    private static final String[] COLORS = {
            "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
            "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf",
            "#aec7e8", "#ffbb78", "#98df8a", "#ff9896", "#c5b0d5",
            "#c49c94", "#f7b6d2", "#dbdb8d", "#9edae5", "#ad494a",
            "#636363", "#393b79", "#5254a3", "#6b6ecf", "#9c9ede"
    };
    // 用于随机生成颜色
    private static final Random RANDOM = new Random();

    /**
     * 获取一个随机颜色
     */
    public static String getRandomColor() {
        return COLORS[RANDOM.nextInt(COLORS.length)];
    }

    /**
     * 按索引循环获取颜色（可用于图表系列配色）
     */
    public static String getColorByIndex(int index) {
        return COLORS[index % COLORS.length];
    }

    /**
     * 获取所有颜色数组（适用于需要遍历的情况）
     */
    public static String[] getAllColors() {
        return COLORS;
    }
}
